package com.wanmait.recruitment.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmait.recruitment.mapper.NationsMapper;
import com.wanmait.recruitment.pojo.Nations;
import com.wanmait.recruitment.service.NationsService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class NationsServiceImpl implements NationsService {
    @Resource
   private NationsMapper nationsMapper;
    @Override
    public void insert(Nations object) {
      nationsMapper.insert(object);
    }

    @Override
    public void delete(Integer id) {

    }

    @Override
    public void delete(String ids) {

    }

    @Override
    public void update(Nations object) {

    }

    @Override
    public Nations findById(Integer id) {
        return null;
    }

    @Override
    @Cacheable("nationsCache")
    public List<Nations> findAll() {
        return nationsMapper.selectFindAll();
    }

    @Override
    public List<Nations> findAll(Nations object) {
        return null;
    }

    @Override
    public PageInfo<Nations> findPage(int pageNum, int pageSize) {

        return null;
    }

 @Override
 public PageInfo<Nations> findPage(int pageNum, int pageSize, String name) {
  PageHelper.startPage(pageNum, pageSize);
  List<Nations>nations = nationsMapper.FindAll(name);
  PageInfo<Nations>pageInfo = new PageInfo<>(nations);
  return pageInfo;
 }

 @Override
 public int deletenable(Integer id) {
  return nationsMapper.deletenable(id);
 }
}
